package eu.robico.simulator.simulatorinterface.actionpanel.objects;

import java.awt.Color;
import java.awt.Graphics2D;

import eu.robico.simulator.simulatorinterface.actionpanel.Position;
import eu.robico.simulator.simulatorinterface.utils.Boundary;

class CrossRoadsObject implements ActionPanelObject 
{
	private Position position;
	private int size = 20;
	
	public CrossRoadsObject(Position position)
	{
		this.position = position;
	}
	
	@Override
	public void paint(Graphics2D graphics) 
	{
		int correction = size / 2;
		graphics.setColor(Color.GRAY);
		graphics.fillRect(position.xAsInt() - correction, position.yAsInt() - correction, size, size);
	}
	
	public Position getPosition()
	{
		return position;
	}
	
	public int getWidth()
	{
		return size;
	}

	public boolean containsPosition(Position position)
	{
		//Get crossroads bounds
		Boundary crossRoadsBounds = Boundary.getRectangleBounds(this.position, size);
		//Check if bounds contain centerpoint
		return crossRoadsBounds.contains(position);
	}
}
